<template>
	<view>
		<view @click="navigator(item.id)" :class="index===list.length-1?'list no':'list'" v-for="(item,index) in list" :key="item.id">
			<image :src="item.img_url"></image>
			<view class="right">
				<view class="tit">
					{{item.title}}
				</view>
				<view class="info">
					<text>发表时间：{{item.add_time | getTime}}</text>
					<text>浏览：{{item.click}}</text>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default{
		props:['list'],
		methods:{
			navigator(id){
				this.$emit('itemClick',id)
			}
		},
		filters:{//过滤器
			//字符串.padStrat(2,0);表示如果字符串是是一位是时，在前面加0
			getTime(time){
				var date = new Date(time),
				year = date.getFullYear(),
				month = date.getMonth() + 1,
				day = date.getDate(),
				hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
				minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
				second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				month >= 1 && month <= 9 ? (month = "0" + month) : "";
				day >= 0 && day <= 9 ? (day = "0" + day) : "";
				var timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
				return timer;
				// console.log(timer);
			},
		}
	}
</script>

<style lang="scss">
	.list{
		display: flex;
		padding: 10rpx 20rpx;
		border-bottom: 1px solid $shop-color;
		image{
			min-width: 200rpx;
			max-width: 200rpx;
			height: 150rpx;
		}
		.right{
			margin-left: 13rpx;
			font-size: 30rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			.info{
				font-size: 25rpx;
				text:nth-child(2){
					margin-left: 30rpx;
				}
			}
		}
	}
	.no{
		border-bottom: none;
	}
</style>
